home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-02 / prodpack.zip / DB4PPSRC.EXE / MAKEITEZ.PRG < prev    next >
Text File  |  1993-05-23  |  7KB  |  217 lines

  1. PROCEDURE MakeItEz
  2. PARAMETERS pc_dbf
  3. *----------------------------------------------------------------------------
  4. * NAME
  5. *   MakeItEz - Takes a design DBF file created with SCR2DBF and gets it
  6. *              ready for code gen.
  7. *
  8. * DESCRIPTION
  9. *   MakeItEz will tie the dialog box controls together to make it easier
  10. *   for code generation.  MakeItEz will do the following:       
  11. *   - Convert the row and column coordinates to match the dialog
  12. *     box window.  MakeItEz will place the new window row in Sys_flen,
  13. *     and the column in Length.
  14. *   - For edit controls, MakeItEz will place the right column of the
  15. *     field based on the template length into Decimals.
  16. *   - MakeItEz will alter the top row value for simple combo boxes 
  17. *     ( "CS_" prefix ) and place the window offset coordinates for the
  18. *     resulting popup into the CS_ object's Descript field as a 
  19. *     FROM ... TO ... clause.  Decimals is Hieght, Length is Width.
  20. *
  21. *   - MakeItEz will store the window definition for the dialog into
  22. *     the first box's Expression field.  MakeItEz will store the window
  23. *     name into the first box's Filename field.
  24. *
  25. * PARAMETERS
  26. *   pc_dbf     = name of the design DBF file with extension.
  27. *
  28. *----------------------------------------------------------------------------
  29.   PRIVATE lc_name, ln_winbotr, ln_winbotc, ln_rowoff, ln_coloff
  30.  
  31.   lc_name = _Proper( pc_dbf )
  32.  
  33.   *------------------------------------------------
  34.   *-- Get the box dimensions for the window offsets
  35.   *------------------------------------------------
  36.   LOCATE FOR value_type = "B"         && Get the first box
  37.   ln_rowoff  = row
  38.   ln_coloff  = col
  39.   ln_winbotr = row + decimals - 1
  40.   ln_winbotc = col + length - 1
  41.  
  42.   lc_windef = "FROM " + ;
  43.               STR( row, 2 ) + "," + STR( col, 2 ) + " TO " + ;
  44.               STR( ln_winbotr, 2 ) + "," + STR( ln_winbotc, 2)
  45.  
  46.   REPLACE filename WITH lc_name, ;
  47.           expression WITH lc_windef
  48.  
  49.   *-----------------------------------------------------------
  50.   *-- Pass over the edit controls, text, and titles to set the
  51.   *-- windows offset coordinates.
  52.   *-----------------------------------------------------------
  53.   GO TOP
  54.   SET FILTER TO 
  55.   SCAN
  56.     *------------------
  57.     *-- Skip over boxes
  58.     *------------------
  59.     IF value_type = "B"
  60.       LOOP
  61.     ENDIF
  62.  
  63.     *------------------------------
  64.     *-- Store the offset coordinate
  65.     *------------------------------
  66.     REPLACE sys_flen WITH row - ln_rowoff, ;
  67.             length   WITH col - ln_coloff
  68.  
  69.     IF value_type = "T"
  70.       REPLACE picfun WITH GetColor( display )
  71.     ENDIF
  72.  
  73.     lc_prefix = LEFT( fieldname, 3 )
  74.     lc_suffix = RIGHT( TRIM( fieldname ), 2 )
  75.  
  76.     *----------------------------------
  77.     *-- Check for a pick key assignment
  78.     *----------------------------------
  79.     ln_pick = AT( "~", template )
  80.     IF ln_pick > 0
  81.       lc_pick = SUBSTR( template, ln_pick + 1, 1 )
  82.       REPLACE pickkey WITH lc_pick
  83.       IF lc_prefix <> "BT_"
  84.         lc_text = LEFT( template, ln_pick - 1 )
  85.         lc_text = lc_text + TRIM( SUBSTR( template, ln_pick + 1 ) )
  86.         REPLACE descript WITH Delimit( lc_text )
  87.       ENDIF
  88.     ENDIF
  89.  
  90.     *----------------------------------------------------
  91.     *-- Check for an edit control to establish click zone
  92.     *----------------------------------------------------
  93.     IF ( lc_suffix = "_1" .AND. lc_prefix $ "EF_,CS_,CD_,CL_,LB_,UD_" ) .OR. ;
  94.        lc_prefix = "BT_" .OR. ;
  95.        ( lc_prefix $ "CK_,RB_,EF_" .AND. lc_suffix <> "_0" )
  96.  
  97.       *-------------------------------------------------------
  98.       *-- Need to do some extra work for buttons to get length
  99.       *-------------------------------------------------------
  100.       IF lc_prefix = "BT_"
  101.         lc_temp = TRIM( template )
  102.         ln_lentemp  = LEN( lc_temp )
  103.  
  104.         IF ln_pick > 0
  105.           lc_text = LEFT( template, ln_pick - 1 )
  106.           lc_text = lc_text + TRIM( SUBSTR( template, ln_pick + 1 ) )
  107.         ELSE
  108.           lc_text = lc_temp
  109.         ENDIF
  110.  
  111.         ln_fldlen = 0
  112.         ln = 1
  113.         DO WHILE ln <= ln_lentemp
  114.           IF SUBSTR( template, ln, 1 ) <> " "
  115.             ln_leadsp = ln - 1
  116.             IF "~" $ lc_temp
  117.               ln_fldlen = ln_lentemp + ln_leadsp - 1
  118.             ELSE
  119.               ln_fldlen = ln_lentemp + ln_leadsp
  120.             ENDIF
  121.             lc_text = lc_text + SPACE( ln_leadsp )
  122.             EXIT
  123.           ENDIF
  124.           ln = ln + 1
  125.         ENDDO
  126.         lc_text = lc_text 
  127.         REPLACE descript WITH Delimit( lc_text )
  128.       ELSE
  129.         ln_fldlen = LEN( TRIM( template ) ) - IIF( ln_pick > 0, 1, 0 )
  130.       ENDIF
  131.  
  132.       REPLACE decimals WITH col + ln_fldlen - 1
  133.     ENDIF
  134.  
  135.     *-----------------------------------------------------
  136.     *-- While we are here, if this is a "CS_" object, then
  137.     *-- get the popup definition
  138.     *-----------------------------------------------------
  139.     IF lc_prefix $ "CS_,CL_,CD_,LB_,UD_"
  140.       lc_fldname = _Proper( TRIM( fieldname ) )
  141.       SKIP
  142.       IF value_type = "B"
  143.         IF .NOT. ( lc_prefix $ "LB_,UD_" )
  144.           REPLACE row WITH row + 1, ;
  145.                   fieldname WITH UPPER( lc_fldname )
  146.         ELSE
  147.           REPLACE fieldname WITH UPPER( lc_fldname )
  148.         ENDIF
  149.         ln_top = row - ln_rowoff
  150.         ln_left = col - ln_coloff
  151.         IF lc_prefix = "UD_"
  152.           lc_popup = "DEFINE WINDOW " + lc_fldname + " FROM " + ;
  153.                      STR( ln_top, 2 ) + "+nRowCls, " + STR( ln_left, 2 ) + "+nCol TO " + ;
  154.                      STR( ln_top + decimals - 1, 2 ) + "+nRowCls, " + ;
  155.                      STR( ln_left + length - 1, 2 ) + "+nCol"
  156.         ELSE
  157.           lc_popup = "DEFINE POPUP " + lc_fldname + " FROM " + ;
  158.                      STR( ln_top, 2 ) + ", " + STR( ln_left, 2 ) + " TO " + ;
  159.                      STR( ln_top + decimals - 1, 2 ) + ", " + ;
  160.                      STR( ln_left + length - 1, 2 )
  161.         ENDIF  
  162.         SKIP -1
  163.  
  164.         REPLACE descript WITH lc_popup
  165.       ELSE
  166.         SKIP -1
  167.       ENDIF
  168.     ENDIF
  169.  
  170.   ENDSCAN
  171.  
  172. RETURN
  173. *-- EOP: MakeItEz WITH pc_dbf
  174.  
  175.  
  176.  
  177. FUNCTION Delimit
  178. PARAMETERS pcString
  179. *----------------------------------------------------------------------------
  180. * DESCRIPTION
  181. *
  182. * PARAMETERS
  183. *   pcString   = 
  184. *
  185. *----------------------------------------------------------------------------
  186.   IF ASC( pcString ) < 32
  187.     IF LEN( pcString ) = 1
  188.       lcResult = "CHR( " + ASC( pcString ) + " )"
  189.     ELSE
  190.       IF LEN( pcString ) = 0
  191.         lcResult = ""
  192.       ELSE
  193.         lcResult = "REPLICATE( CHR( " + ASC( pcString ) + " ), " + ;
  194.                     STR( LEN( pcString ) ) + " )"
  195.       ENDIF
  196.     ENDIF
  197.   ELSE
  198.     cLeft= '"'
  199.     cRight = '"'
  200.     IF AT( '"', pcString ) > 0
  201.       IF AT( "'", pcString ) > 0
  202.         cLeft = "["
  203.         cRight = "]"
  204.       ELSE
  205.         cLeft = "'"
  206.         cRight = "'"
  207.       ENDIF
  208.     ENDIF
  209.     lcResult = cLeft + pcString + cRight
  210.   ENDIF
  211.  
  212. RETURN( lcResult )
  213. *-- EOF: Delimit( pcString )
  214.